package 结构型.代理;

public class Main {
    public static void main(String[] args) {

        Hello hello = (Hello) java.lang.reflect.Proxy.newProxyInstance(Hello.class.getClassLoader(), new Class[]{Hello.class},
                (proxy, method, args1) -> {
                    System.out.println(method);
                    if (method.getName().equals("morning")) {
                        System.out.println("Good morning, " + args1[0]);
                    }
                    return proxy;
                });
        hello.morning("Bob");
    }
}

interface Hello {
    void morning(String name);
}
